Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bsp

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bsp

Basic Socket Protocol

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Basic Socket Protocol

install

npm i bsp

Purpose

To transfer as many types of data as possible in NodeJS and automatically handle incomplete data. Currently these types are supported:

  • string
  • number
  • boolean
  • symbol not the same symbol as original, just a new symbol with the same description.
  • undefined
  • null
  • object
  • Array only the enumerable elements will be transferred.
  • Buffer
  • Date
  • Error
  • RegExp

Usage

import * as net from "net";
import { send, receive } from "bsp";

var server = net.createServer(socket => {
    let remains = []; // a container to store remaining/incomplete data.

    socket.on("data", buf => {
        for (let [msg] of receive(buf, remains)) {
            // the first message would be 'Hello, World!'
        }
    });
});

server.listen(8000, () => {
    var socket = net.createConnection(8000);

    socket.on("connect", () => {
        socket.write(send("Hello, World!"));
    });
});

API

  • send(...data: any[]): Buffer
  • receive(buf: Buffer, remains: Buffer[]): IterableIterator<any[]>

Keywords

FAQs

Package last updated on 08 Dec 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc